#include <stdio.h>
#include <string.h>
#include <ctype.h>

using namespace std;

int main() {
    char buf[10];
    scanf("%s", buf);
    long long ans = 0;
    int len = strlen(buf);
    for (int i=0;i<len;++i) {
        char c = buf[i];
        int d = isdigit(c) ? c-'0' : c-'A' + 10;
        ans = ans * 16 + d;
    }
    printf("%lld\n", ans);
}